/**
 * 这是seach页面的模块
 */

import { reqGetSearchGoodsInfoData } from "@/api"

const state = {
  goodsInfo:{}
}
const actions = {
  async getSearchGoodsInfoData({ commit},searchParams) {
    const result = await reqGetSearchGoodsInfoData(searchParams)
    if (result.code === 200) {
      commit('SAVE_SEARCH_INFO_DATA',result.data)
    } else {
      console.log(result.message);
    }
  }
}
const mutations = {
  SAVE_SEARCH_INFO_DATA(state,goodsInfo) {
    state.goodsInfo = goodsInfo
  }
}
// getters就相当于是vuex中的计算属性  可以对state中的数据做进一步的优化处理
const getters = {
  goodsList(state) {
    return state.goodsInfo.goodsList
  },
  attrsList(state) {
    return state.goodsInfo.attrsList
  },
  trademarkList(state) {
    return state.goodsInfo.trademarkList
  },
  total(state) {
    return state.goodsInfo.total
  }
}

export default {
  namespaced:true,  // 开启命名空间
  state,
  actions,
  mutations,
  getters
}